package com.hspedu.override;
/*
1) 编写一个 Person 类，包括属性/private（name、age），构造器、方法 say(返回自我介绍的字符串）。
2) 编写一个 Student 类，继承 Person 类，增加 id、score 属性/private，以及构造器，定义 say 方法(返回自我介绍的信息)。
3) 在 main 中,分别创建 Person 和 Student 对象，调用 say 方法输出自我介绍
代码

 */
public class OverrideExerciae {
    public static void main(String[] args) {

        Person person = new Person("jack",12);
        System.out.println(person.say());
        System.out.println();
        Student student = new Student("jack",12,"a422034",80);
        System.out.println(person.say());

    }
}

class Person{
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String say(){
        return "我的名字是 " + name + ",我的年龄是 " + age;
    }

}

class Student extends Person {
    private String id;
    private double score;

    public Student(String name, int age, String id, double score) {
        super(name, age);
        this.id = id;
        this.score = score;
    }
    public Student(){

    }

    public String say(){
        return super.say() + " id:" + id + " score : " + score;
    }
}
